﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Web;

namespace Stamp_For_Africa_Version_2.Models
{
  public partial class StampFeature
  {
    public bool IsValid
    {
      get { return (GetRuleViolations().Count() == 0); }
    }

    public IEnumerable<RuleViolation> GetRuleViolations()
    {
      if (Features == null)
        yield return new RuleViolation("Stamp features required", "Features");

      yield break;
    }

    partial void OnValidate(ChangeAction action)
    {
      if (!IsValid)
        throw new ApplicationException("Rule violations prevent saving");
    }
  }
}